package cn.kgc.controller.logic.administrative;


import cn.kgc.pojo.Dict;
import cn.kgc.pojo.Meetingreserve;
import cn.kgc.service.administrative.nbw_meetingYDGLService;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/nmydgl")
public class nbw_meetingYDGLController {

    @Resource
    private nbw_meetingYDGLService ydgl;


    @RequestMapping("/indexYDGL")
    public String indexYD(){
        return "administrative/nbw-indexYDGL";
    }

    @RequestMapping("selMeetingtypeId")
    @ResponseBody
    public String selMeetingtypeId(){
        List<Dict> list=ydgl.selMeetingtypeId();
        return JSON.toJSONString(list);
    }

    @RequestMapping("selMeetingreserve")
    @ResponseBody
    public String selMeetingreserve(@RequestParam Integer currentPage,
                                    @RequestParam Integer pageSize,
                                    @RequestParam Integer m_id,
                                    @RequestParam Integer u_id,
                                    @RequestParam String endtime,
                                    @RequestParam String use){
        //使用分页插件核心代码
        PageHelper.startPage(currentPage,pageSize);
        List<Meetingreserve> list=ydgl.selMeetingreserve(m_id,u_id,endtime,use);
        PageInfo<Meetingreserve> pageInfo=new PageInfo<>(list);
        return JSON.toJSONStringWithDateFormat(pageInfo,"yyyy-MM-dd HH:mm:ss");
    }

    @RequestMapping("delindexYDGL")
    @ResponseBody
    public boolean del(@RequestParam Integer id){
        boolean bo=ydgl.del(id);
        return bo;
    }
}
